package com.tentact.servlets;

import com.tentact.service.DeptService;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "deleteDeptServlet", value = "/deleteDeptServlet")
public class deleteDeptServlet extends HttpServlet {
    DeptService service =new DeptService();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("进入删除servlet");

        int departmentid =Integer.parseInt(request.getParameter("departmentid"));
        System.out.println(departmentid);


        if (service.deleteByDept(departmentid)!=1){
            System.out.println("删除失败");
        }else{
            request.getRequestDispatcher("selectDeptServlet").forward(request,response);
        }

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }
}
